package com.ruoyi.locate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.locate.domain.WWarehouseMap;
import com.ruoyi.locate.service.IWWarehouseMapService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓位地图Controller
 * 
 * @author ruoyi
 * @date 2025-01-07 08:00:58
 */
@RestController
@RequestMapping("/locates/map")
public class WWarehouseMapController extends BaseController
{
    @Autowired
    private IWWarehouseMapService wWarehouseMapService;

    /**
     * 查询仓位地图列表
     */
    @PreAuthorize("@ss.hasPermi('locates:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(WWarehouseMap wWarehouseMap)
    {
        startPage();
        List<WWarehouseMap> list = wWarehouseMapService.selectWWarehouseMapList(wWarehouseMap);
        return getDataTable(list);
    }

    /**
     * 导出仓位地图列表
     */
    @PreAuthorize("@ss.hasPermi('locates:map:export')")
    @Log(title = "仓位地图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WWarehouseMap wWarehouseMap)
    {
        List<WWarehouseMap> list = wWarehouseMapService.selectWWarehouseMapList(wWarehouseMap);
        ExcelUtil<WWarehouseMap> util = new ExcelUtil<WWarehouseMap>(WWarehouseMap.class);
        util.exportExcel(response, list, "仓位地图数据");
    }

    /**
     * 获取仓位地图详细信息
     */
    @PreAuthorize("@ss.hasPermi('locates:map:query')")
    @GetMapping(value = "/{mapId}")
    public AjaxResult getInfo(@PathVariable("mapId") Long mapId)
    {
        return success(wWarehouseMapService.selectWWarehouseMapByMapId(mapId));
    }

    /**
     * 新增仓位地图
     */
    @PreAuthorize("@ss.hasPermi('locates:map:add')")
    @Log(title = "仓位地图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WWarehouseMap wWarehouseMap)
    {
        wWarehouseMap.setCreateBy(getNickName());
        return toAjax(wWarehouseMapService.insertWWarehouseMap(wWarehouseMap));
    }

    /**
     * 修改仓位地图
     */
    @PreAuthorize("@ss.hasPermi('locates:map:edit')")
    @Log(title = "仓位地图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WWarehouseMap wWarehouseMap)
    {
        wWarehouseMap.setUpdateBy(getNickName());
        return toAjax(wWarehouseMapService.updateWWarehouseMap(wWarehouseMap));
    }

    /**
     * 删除仓位地图
     */
    @PreAuthorize("@ss.hasPermi('locates:map:remove')")
    @Log(title = "仓位地图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mapIds}")
    public AjaxResult remove(@PathVariable Long[] mapIds)
    {
        return toAjax(wWarehouseMapService.deleteWWarehouseMapByMapIds(mapIds));
    }

    /**
     * 获取仓位地图详细信息
     */
    //@PreAuthorize("@ss.hasPermi('locates:map:query')")
    @GetMapping("/listoption")
    public AjaxResult listoption()
    {
        return success(wWarehouseMapService.selectWWarehouseMapAll());
    }
}
